package com.shuaqiu.simback.service;

import javax.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

/**
 * @author shuaqiu on 2013-10-03.
 */
@Path("/simple")
@Named
public class SimpleService {

    private TestBean bean;

    @Inject
    public void setBean(TestBean bean) {
        this.bean = bean;
    }

    @GET
    @Path("/helloworld")
    @Produces(value = MediaType.TEXT_PLAIN)
    public String hello() throws HeadStatusException{
        return "Hello World! " + bean.getName();
    }

    @GET
    @Path("/hellojson")
    @Produces(value = MediaType.APPLICATION_JSON)
    public TestBean json(){
        return bean;
    }

    @GET
    @Path("/exception")
    @Produces(MediaType.TEXT_PLAIN)
    public String exception() throws HeadStatusException{
        throw new HeadStatusException("test exception");
    }
}
